/*----------------------------------------------------------------------------
 * osObjects.h: CMSIS-RTOS global object definitions for an application
 *----------------------------------------------------------------------------
 *
 * This header file defines global RTOS objects used throughout a project
 *
 * #define osObjectsPublic indicates that objects are defined; without that
 * definition the objects are defined as external symbols.
 *
 *--------------------------------------------------------------------------*/


#ifndef __osObjects
#define __osObjects

#if (!defined (osObjectsPublic))
#define osObjectsExternal           // define RTOS objects with extern attribute
#endif

#ifdef osObjectsPublic
#define OBJ_EXT  
#else
#define OBJ_EXT extern 
#endif

#include "cmsis_os.h"               // CMSIS RTOS header file


// global 'thread' functions ---------------------------------------------------

int Init_Thread (void);
int Init_Mutex (void);

void SysTask (void const *argument);                             // thread function
OBJ_EXT osThreadId tid_SysTask;                                  // thread id
osThreadDef (SysTask, osPriorityNormal, 1, 0);                   // thread object


/*
void GuiTask (void const *argument);                             // thread function
OBJ_EXT osThreadId tid_GuiTask;                                  // thread id
osThreadDef (GuiTask, osPriorityBelowNormal, 1, 0);              // thread object
*/
void TempTask (void const *argument);                             // thread function
OBJ_EXT osThreadId tid_TempTask;                                  // thread id
osThreadDef (TempTask, osPriorityAboveNormal, 1, 0);              // thread object

void TempCtrTask (void const *argument);                          // thread function
OBJ_EXT osThreadId tid_TempCtrTask;                               // thread id
osThreadDef (TempCtrTask, osPriorityHigh, 1, 0);                  // thread object

/*
void WifiTask (void const *argument);                            // thread function
OBJ_EXT osThreadId tid_WifiTask;                                 // thread id
osThreadDef (WifiTask, osPriorityAboveNormal, 1, 0);             // thread object
*/

void ModbusTask (void const *argument);                           // thread function
OBJ_EXT osThreadId tid_ModbusTask;                                // thread id
osThreadDef (ModbusTask, osPriorityAboveNormal, 1, 0);            // thread object



void SaveTask (void const *argument);                            // thread function
OBJ_EXT osThreadId tid_SaveTask;                                 // thread id
osThreadDef (SaveTask, osPriorityBelowNormal, 1, 0);             // thread object


void LedCtrTask (void const *argument);                            // thread function
OBJ_EXT osThreadId tid_LedCtrTask;                                 // thread id
osThreadDef (LedCtrTask, osPriorityBelowNormal, 1, 0);             // thread object

//void Thread (void const *argument);                               // thread function
//OBJ_EXT osThreadId tid_Thread;                                    // thread id
//osThreadDef (Thread, osPriorityBelowNormal, 1, 0);                // thread object

void StorageTaskEntry (void const *argument);                           // thread function
OBJ_EXT osThreadId tid_StrCtrTask;                                // thread id
osThreadDef (StorageTaskEntry, osPriorityBelowNormal, 1, 0);            // thread object

// global 'semaphores' ----------------------------------------------------------

OBJ_EXT osSemaphoreId sid_SemComRx;                              // semaphore id
osSemaphoreDef (SemComRx);                                       // semaphore object

// global 'mutex' ----------------------------------------------------------

OBJ_EXT osMutexId mid_I2cMutex;                                  // mutex id
osMutexDef (I2cMutex);                                           // mutex name definition

OBJ_EXT osMutexId mid_TimeMutex;                                 // mutex id , protect TimeCur
osMutexDef (TimeMutex);                                          // mutex name definition

OBJ_EXT osMutexId mid_mbMutex;                                   // mutex id , protect TimeCur
osMutexDef (mbMutex);                                            // mutex name definition

OBJ_EXT osMutexId mid_StrMutex;                                  // mutex id , protect TimeCur
osMutexDef (StrMutex);                                           // mutex name definition

// global 'memory pools' --------------------------------------------------------
/* 
Example:
typedef struct sample_name type_sample_name;            // object data type

osPoolId mpid_sample_name;                              // memory pool id
osPoolDef (sample_name, 16, type_sample_name);          // memory pool object
*/


// global 'message queues' -------------------------------------------------------
/* 
Example:
typedef struct sample_name type_sample_name;            // object data type

osMessageQId mid_sample_name;                           // message queue id
osMessageQDef (sample_name, 16, type_sample_name);      // message queue object
*/


// global 'mail queues' ----------------------------------------------------------
/* 
Example:
typedef struct sample_name type_sample_name;            // object data type

osMailQId qid_sample_name;                              // mail queue id
osMailQDef (sample_name, 16, type_sample_name);         // mail queue object
*/

#endif  // __osObjects
